//
//  WelcomeViewController.m
//  HaierGMS_APP
//
//  Created by 堂堂 on 16/11/21.
//  Copyright © 2016年 堂堂. All rights reserved.
//

#import "WelcomeViewController.h"
#import "Prefix.h"
#import "UIColor+Hex.h"
#import "LoginViewController.h"
#import "UserDefaultUtil.h"
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height//获取屏幕高度，兼容性测试
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度，兼容性测试
@interface WelcomeViewController ()
@property UIButton *button;
@end

@implementation WelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
   // [self.view addSubview:_sdScrollView];
   // self.view.backgroundColor = [UIColor lightGrayColor];
    NSArray *imagesURLStrings = @[
                                  @"welcome_1.jpg",
                                  @"welcome_2.jpg",
                                  @"welcome_3.jpg"
                                  ];
    
    
    self.sdScrollView.localizationImageNamesGroup = imagesURLStrings;
    self.sdScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    self.sdScrollView.delegate = self;
    self.sdScrollView.currentPageDotColor = [UIColor whiteColor]; // 自定义分页控件小圆标颜色
    self.sdScrollView.placeholderImage = [UIImage imageNamed:@"placeholder"];
    self.sdScrollView.autoScroll = NO;
    self.sdScrollView.infiniteLoop = NO;
    self.sdScrollView.showPageControl = NO;


    _button = [[UIButton alloc]initWithFrame:AUTOFITSCREEN_FOR_COORDINATE((ScreenWidth - 150) / 2, ScreenHeight - 100, 150, 45)];
    [_button setTitleColor:[UIColor colorWithHexString:@"#ff7e00"] forState:UIControlStateNormal];
        [_button setTitleColor:[UIColor colorWithHexString:@"#ff7e00"] forState:UIControlStateSelected];
    [_button setTitle:@"欢迎使用" forState:UIControlStateNormal];
    [_button setTitle:@"欢迎使用" forState:UIControlStateSelected];
    _button.hidden = YES;
    [self.view addSubview:_button];
    [UserDefaultUtil saveData:@"tt" key:USER_FIRST];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/** 图片滚动回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index{
//    if (index == 2) {
//        _button.hidden = NO;
//        [_button.layer setBorderWidth:1];
//        [_button.layer setBorderColor:[UIColor colorWithHexString:@"ff7e00"].CGColor];
//
//    }else{
//        _button.hidden = YES;
//        [_button.layer setBorderWidth:0];
//        [_button.layer setBorderColor:[UIColor clearColor].CGColor];
//
//    }
}

/** 点击图片回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    
    if (index == 2) {
        //跳转
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"App_Main" bundle:[NSBundle mainBundle]];
        //由storyboardID获取TabBarViewController
        LoginViewController * myTabBarController = [storyboard instantiateViewControllerWithIdentifier:@"login_view"];
        
        [self presentViewController:myTabBarController animated:YES completion:nil];
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
